Skip to content

Fix davidson-harel layout crash on graphs > 1024 nodes (#362)#373

Open
AllenLarocque wants to merge 1 commit into
grunwaldlab:masterfrom
AllenLarocque:fix/davidson-harel-noninteger-fineiter
Open

Fix davidson-harel layout crash on graphs > 1024 nodes (#362)#373
AllenLarocque wants to merge 1 commit into
grunwaldlab:masterfrom
AllenLarocque:fix/davidson-harel-noninteger-fineiter

Conversation

@AllenLarocque

@AllenLarocque AllenLarocque commented Jul 9, 2026

Copy link
Copy Markdown

Fixes #362. It turns out AI can figure out stuff that I can't :)

Problem

heat_tree(..., layout = "davidson-harel") errors on larger graphs:

Error: At rinterface_extra.c:82 : The value 10.642051692927977 is not representable as an integer. Invalid value

Root cause

igraph::layout_with_dh() requires an integer fineiter. In layout_functions() (R/heat_tree--layouts.R) it is computed as:

fineiter = max(10, log2(igraph::vcount(graph))) * effort

log2(vcount) becomes non-integer as soon as a (connected component of the) graph exceeds 1024 nodes (2^10) — e.g. log2(1598) ≈ 10.64, the exact value in the error. igraph then rejects it. This is why the crash is size-dependent: small graphs (and forests of small components, which metacoder lays out per-component) stay under the threshold, while a single large connected tree trips it.

Fix

Round fineiter to an integer (and maxiter, defensively, in case effort is non-integer). Behaviour is unchanged below 1024 nodes; above it, the layout now runs instead of erroring.

Verification

  • igraph::layout_with_dh(g, fineiter = log2(vcount(g))) reproduces the error on a >1024-node graph; fineiter = round(...) succeeds.
  • With the fix, heat_tree(layout = "davidson-harel") renders a real ~1,500-node taxonomic tree that previously crashed.

Reported by several users over the last few years in #362 — hopefully this unblocks them.

🤖 Generated with Claude Code

heat_tree(layout = "davidson-harel") errored with "The value <x> is not
representable as an integer. Invalid value" from igraph whenever a connected
component of the graph exceeded 1024 nodes.

igraph::layout_with_dh() requires an integer `fineiter`, but layout_functions()
computed it as `max(10, log2(vcount(graph))) * effort`. `log2(vcount)` is
non-integer once vcount > 1024 (2^10), so igraph rejected it. Round `fineiter`
(and `maxiter`, defensively for non-integer `effort`) to integers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant